package pt.uma.gap.graph;

/**
 * Represents graph edge from/to node
 * 
 * @author Duarte Abreu
 *
 */
public class Edge {
	
	public enum EdgeType{ R, W, P }
	
	private GraphNode from;
	private GraphNode to;
	private String edgeType;
	
	/*
	 * This is test comment by Ijaz
	 */
	/** Comment by Duarte
	 * @param from
	 * @param to
	 * @param edgeType
	 * @throws Exception
	 */
	public Edge(GraphNode from, GraphNode to, String edgeType) throws NullEdgeNodeException {
		
		if(from == null){
			throw new NullEdgeNodeException("Edge 'from' node can not be null");
		}
		if(to == null){
			throw new NullEdgeNodeException("Edge 'to' node can not be null");
		}
		this.from = from;
		this.to = to;
		this.edgeType = edgeType;
	}
	
	public String getEdgeType() {
		return edgeType;
	}
	
	public GraphNode getFrom() {
		return from;
	}
	public void setFrom(GraphNode from) {
		this.from = from;
	}
	public GraphNode getTo() {
		return to;
	}
	public void setTo(GraphNode to) {
		this.to = to;
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Edge){
			Edge checkEdge =  (Edge)obj;
			return this.getTo().equals(checkEdge.getTo())
				&& this.getFrom().equals(checkEdge.getFrom())
			;
		}
		return false;
	}

}
